import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;

import javax.swing.JComponent;

public class MapRender extends JComponent {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8288694968033557933L;
	public int[][] map = { { 0, 1, 7, 1, 8 }, { 1, 5, 1, 0, 1 },
			{ 0, 1, 0, 1, 0 } };

	public final Color[] intToColor = { Color.BLACK, Color.BLUE, Color.CYAN,
			Color.DARK_GRAY, Color.GRAY, Color.GREEN, Color.LIGHT_GRAY,
			Color.MAGENTA, Color.ORANGE, Color.PINK, Color.RED, Color.WHITE,
			Color.YELLOW };

	public void paint(Graphics g) {
		Rectangle clip = g.getClipBounds();
		float cellWidth = (float)clip.width / map.length;
		float cellHeight = (float)clip.height / map[0].length;
		for (int x = 0; x < map.length; x++) {
			for (int y = 0; y < map[0].length; y++) {
				g.setColor(intToColor[map[x][y]]);
				g.fillRect(Math.round(x * cellWidth), Math.round(y * cellHeight), Math.round(cellWidth), Math.round(cellHeight));
			}

		}
	}
}
